如想用 SMTP 代替 Sendmail 发送email,添加如下相应邮箱服务商的配置到/etc/gitlab/gitlab.rb, 然后运行gitlab-ctl reconfigure使修改生效。 omnibus-gitlab还提供了测试发送邮件功能。
注意:smtp_password
字段不应包含任何 Ruby或者YAML语法中的分隔符 (如'
), 以避免处理配置文件的过程中发生不必要的意外。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.server" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "smtp user" gitlab_rails['smtp_password'] = "smtp password" gitlab_rails['smtp_domain'] = "example.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com' Example configuration 配置示例
|
Example configuration配置示例
SMTP on localhost
下面的配置仅仅是启动smtp,值为false
则使用默认的设置(sendmail),启用smtp可用于不提供sendmail
接口或者与gitlab不兼容的sendmail
接口的运行MTA的本地服务器,如“Exim”。
QQ exmail (腾讯企业邮箱)
1 2 3 4 5 6 7 8 9
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.exmail.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "xxxx@xx.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
|
Gmail
注意:Gmail具有严格的发送限制,可能会随着组织的发展而影响功能。 强烈建议为使用SMTP配置的团队使用SendGrid或Mailgun等事务服务。
1 2 3 4 5 6 7 8 9 10
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.gmail.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "my.email@gmail.com" gitlab_rails['smtp_password'] = "my-gmail-password" gitlab_rails['smtp_domain'] = "smtp.gmail.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
|
不要忘记将my.email@gmail.com更改为您的电子邮件地址,将my-gmail-password更改为您自己的密码。
如果您遇到身份验证错误,请确保您允许安全性较低的应用访问该帐户,或尝试启用两步验证并使用应用程序密码。
Mailgun
1 2 3 4 5 6 7 8
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.mailgun.org" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_authentication'] = "plain" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_user_name'] = "postmaster@mg.gitlab.com" gitlab_rails['smtp_password'] = "8b6ffrmle180" gitlab_rails['smtp_domain'] = "mg.gitlab.com"
|
Amazon SES
1 2 3 4 5 6 7 8
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "email-smtp.region-1.amazonaws.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "IAMmailerKey" gitlab_rails['smtp_password'] = "IAMmailerSecret" gitlab_rails['smtp_domain'] = "yourdomain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true
|
Mandrill
1 2 3 4 5 6 7
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.mandrillapp.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "MandrillUsername" gitlab_rails['smtp_password'] = "MandrillApiKey" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true
|
SparkPost
1 2 3 4 5 6 7
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.sparkpostmail.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "SMTP_Injection" gitlab_rails['smtp_password'] = "SparkPost_API_KEY" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true
|
Gandi
1 2 3 4 5 6 7 8
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "mail.gandi.net" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_authentication'] = "plain" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_user_name'] = "your.email@domain.com" gitlab_rails['smtp_password'] = "your.password" gitlab_rails['smtp_domain'] = "domain.com"
|
Zoho Mail
这个配置是在Zoho Mail上用自定义域进行测试的。
1 2 3 4 5 6 7 8 9 10
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.zoho.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_authentication'] = "plain" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_user_name'] = "gitlab@mydomain.com" gitlab_rails['smtp_password'] = "mypassword" gitlab_rails['smtp_domain'] = "smtp.zoho.com" gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'
|
OVH
1 2 3 4 5 6 7 8 9 10
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "ssl0.ovh.net" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "username@domain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "ssl0.ovh.net" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'none'
|
Outlook
1 2 3 4 5 6 7 8 9
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp-mail.outlook.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "username@outlook.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "smtp-mail.outlook.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
|
Online.net
1 2 3 4 5 6 7 8 9 10
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtpauth.online.net" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "username@domain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "online.net" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'none'
|
Amen.fr / Securemail.pro
1 2 3 4 5 6
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp-fr.securemail.pro" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "username@domain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_tls'] = true
|
1&1
1 2 3 4 5 6 7 8
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.1and1.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "my.email@domain.com" gitlab_rails['smtp_password'] = "1and1-email-password" gitlab_rails['smtp_domain'] = "domain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true
|
yahoo
1 2 3 4 5 6 7 8 9 10 11 12
| gitlab_rails['gitlab_email_from'] = 'user@yahoo.com' gitlab_rails['gitlab_email_from'] = 'user@yahoo.com' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.mail.yahoo.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "user@yahoo.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
|
Sendgrid
1 2 3 4 5 6 7 8 9
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.sendgrid.net" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "a_sendgrid_crendential" gitlab_rails['smtp_password'] = "a_sendgrid_password" gitlab_rails['smtp_domain'] = "smtp.sendgrid.net" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false
|
Yandex
1 2 3 4 5 6 7 8 9
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.yandex.ru" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "login" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "yourdomain_or_yandex.ru" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "mail.udXX.udmedia.de" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "login" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer' Microsoft Exchange (No authentication) gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "example.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_domain'] = "example.com" gitlab_rails['smtp_authentication'] = false gitlab_rails['smtp_enable_starttls_auto'] = true
|
Strato.de
1 2 3 4 5 6 7 8 9 10
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.strato.de" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "username@stratodomain.de" gitlab_rails['smtp_password'] = "strato_email_password" gitlab_rails['smtp_domain'] = "strato.de" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'none'
|
Rackspace
1 2 3 4 5 6 7 8 9 10 11 12 13
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "secure.emailsrvr.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "username@domain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "domain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['gitlab_email_from'] = 'username@domain.com' gitlab_rails['gitlab_email_reply_to'] = 'username@domain.com'
|
DomainFactory (df.eu)
1 2 3 4 5 6 7 8 9 10
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "sslout.df.eu" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "username@domain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "domain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'none'
|
Infomaniak (infomaniak.com)
1 2 3 4 5 6 7 8 9 10
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "mail.infomaniak.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "username" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "mail.infomaniak.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'none'
|
GoDaddy (No TLS)
1 2 3 4 5 6 7 8 9
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtpout.secureserver.net" gitlab_rails['smtp_port'] = 80 gitlab_rails['smtp_user_name'] = "username@domain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "domain.com" gitlab_rails['smtp_authentication'] = "plain" gitlab_rails['smtp_enable_starttls_auto'] = false gitlab_rails['smtp_tls'] = false
|
OpenSRS (hostedemail.com)
1 2 3 4 5 6 7 8 9 10 11 12 13
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "mail.hostedemail.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "username@domain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "domain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_enable_starttls_auto'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['gitlab_email_from'] = 'username@domain.com' gitlab_rails['gitlab_email_reply_to'] = 'username@domain.com'
|
Aruba (aruba.it)
1 2 3 4 5 6 7 8
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtps.aruba.it" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "user@yourdomain.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "yourdomain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_ssl'] = true
|
Aliyun Direct Mail(阿里云邮件推送)
1 2 3 4 5 6 7 8
| gitlab_rails['gitlab_email_from'] = 'username@your domain' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtpdm.aliyun.com" gitlab_rails['smtp_port'] = 80 gitlab_rails['smtp_user_name'] = "username@your domain" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_domain'] = "your domain" gitlab_rails['smtp_authentication'] = "login"
|
FastMail
即使未启用两步验证,FastMail也需要应用程序密码。
1 2 3 4 5 6 7 8
| gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.fastmail.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "account@fastmail.com" gitlab_rails['smtp_password'] = "app-specific-password" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
|
Dinahosting
1 2 3 4 5 6 7 8 9 10 11
| gitlab_rails['gitlab_email_from'] = 'username@example.com' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "example-com.correoseguro.dinaserver.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "username-example-com" gitlab_rails['smtp_password'] = "mypassword" gitlab_rails['smtp_domain'] = "example-com.correoseguro.dinaserver.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = false gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
|
Testing the SMTP configuration 测试配置是否成功
配置完成后可以用Rails控制台验证邮件是否能发送成功。 在GitLab服务器上,执行 gitlab-rails console 进入控制台。 然后在控制台提示符后输入下面的命令 发送一封测试邮件:
1 2 3
| irb(main):003:0> Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now Notify.test_email('收件人邮箱', '邮件标题', '邮件正文').deliver_now
|